import React, {Component} from 'react';
import {HashRouter, Route, Redirect, Switch} from "react-router-dom";
import Films from "../view/Films";
import Cimemas from "../view/Cimemas";
import Center from "../view/Center";
import NotFound from "../view/NotFound";
import NowPlaying from "../view/film/NowPlaying";

export default class IndexRouter extends Component {
    render() {
        return (
            <div>
                <HashRouter>
                    {this.props.children}
                    <Switch>
                        {/*嵌套路由不能用exact*/}
                        <Route path="/films" component={Films}></Route>
                        {/*<Route path="/films/nowPlaying" component={NowPlaying}></Route>*/}



                        <Route path="/cimemas" component={Cimemas}></Route>
                        <Route path="/center" component={Center}></Route>

                        {/*路由重定向*/}
                        {/*模糊匹配*/}
                        {/*加上exact,意思是只有斜杆才会匹配films*/}
                        <Redirect from="/" to="/films" exact></Redirect>

                        {/*精确匹配m,exact*/}
                        <Route component={NotFound}></Route>
                    </Switch>
                </HashRouter>
            </div>
        );
    }
}